const baseInstallationModel = require('../model/baseInstallation');

async function addBaseInstallation (req, res, next) {
    try {
        const userId = req.user.userId;
        const {title} = req.body;
        await baseInstallationModel.create({title, author: userId})
        res.json({
            code: 200,
            msg: '新建基础设施成功'
        })
    } catch(err) {
        next(err)
    }
}

async function getBaseInstallation (req, res, next) {
    try {
        const data = await baseInstallationModel.find()
        res.json({
            code: 200,
            data
        })
    } catch(err) {
        next(err)
    }
}

module.exports = {
    addBaseInstallation,
    getBaseInstallation
}
